package com.ubank.transfer;

import java.util.HashMap;
import java.util.List;

import com.ubank.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ContentListAdapter extends BaseAdapter
{
	Context							context;
	List<HashMap<String, Object>>	content_list;
	boolean							isLeftImageVisible;

	public ContentListAdapter(Context context,
			List<HashMap<String, Object>> list, boolean isVisible)
	{
		this.context = context;
		this.content_list = list;
		this.isLeftImageVisible = isVisible;
	}

	public int getCount()
	{
		return content_list.size();
	}

	public Object getItem(int arg0)
	{
		return content_list.get(arg0).get("midText");
	}

	public long getItemId(int position)
	{
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent)
	{
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View itemView = inflater.inflate(R.layout.listitemtemplate, null);
		TextView midText = (TextView) itemView.findViewById(R.id.lItemTitle);
		midText.setText(this.getItem(position).toString());

		if (!isLeftImageVisible)
		{
			ImageView left = (ImageView) itemView
					.findViewById(R.id.lItemFrontImage);
			left.setVisibility(View.INVISIBLE);
		}
		return itemView;
	}
}
